#!/bin/bash

source $DRAW_INI
source $DRAW_CFG

# removed -bm EMPIRICAL for more recent GATK
# 2011-11-11: added --read_filter MappingQuality for -mmq


java -Xmx4g -jar $GATK \
 -l INFO \
 -R $REF_FASTA \
 -T UnifiedGenotyper \
 -et NO_ET \
 -mbq $4 \
 --read_filter MappingQuality -mmq $5 \
 --genotype_likelihoods_model BOTH \
 -nt $GATK_THREADS \
 -D $SNPDB \
 -I s_${1}${2}.bam \
 -o ${3}/s_${1}${2}_mbq_${4}_mmq_${5}.vcf

EXITSTATUS=$?

if [ ! -s "${3}/s_${1}${2}_mbq_${4}_mmq_${5}.vcf" ]; then exit 100;fi;

if [ $(grep -cv "^#" "${3}/s_${1}${2}_mbq_${4}_mmq_${5}.vcf") -eq "0" ]
 then
  echo "problem, no SNPs!"
  exit 100;
fi


if [ $EXITSTATUS -ne 0 ];then exit $EXITSTATUS;fi

